package org.strangewt.demo.composit;

import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.strangewt.demo.testdata.Project;
import org.strangewt.widgets.CompositeInput;


public class CompositeProject extends CompositeInput<Project> {

	private Text txName;
	private Text txDescription;

	public CompositeProject(Composite parent, int style) {
		super(parent, style);

		createControl(this);
	}

	private void createControl(Composite parent) {
		
		setLayout(new GridLayout(2, false));
	
		createLabel(parent, getClass().getName(), 2, 1);
		
		createLabel(parent, "name");
		txName = createText(parent);
		
		createLabelTop(parent, "description");
		txDescription = createTextField(parent, 0, 80);
	}
	
	@Override
	public void setInput(Project input) {
		
		txName.setText(input.getName());
		txDescription.setText(input.getDescription());
		
		super.setInput(input);
	}
}
